﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iITT.iITT_Services;

namespace WebApplication4
{
    public partial class WeatherConfig : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int zip;

            if (int.TryParse(TextBox1.Text, out zip) && TextBox1.Text.Trim().Length == 5) {
              
               string config = TextBox1.Text.Trim();
               iITT_Services sendInfo = new iITT_Services();
               sendInfo.AddWidget("Tchazzar", 2, "0", config);
               Response.Write("<script> alert('Settings saved. Taking you back to widget store.');</script>");
               ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);
               // Call method to submit to database.  use 'config' string as settings element.
            }

            else {

              Response.Write("<script> alert('The zip code entered is invalid');</script>");
            }
        }
    }
}